<template>
  <el-row v-if="optionsList.length>0">
    <template v-for="item in optionsList" :key="item.label">
      <el-tooltip :show-after="500" class="item" effect="dark" :content="getLabel(item)" placement="top">
        <el-button :class="{'is-active': item.value}" size="small" circle :icon="item.icon" @click="item.click()" />
      </el-tooltip>
    </template>
  </el-row>
</template>

<script setup>

defineOptions({
  name: 'CustomizeToolbar'
})

const props = defineProps({
  options: {
    type: Array,
    default: () => []
  }
})

const optionsList = computed(() => ([...props.options]))


const getLabel = (item) => {
  if (typeof item.label === 'string') return item.label
  else return item.value ? item.label[0] : item.label[1] || item.label[0]
}


</script>

<style scoped lang="scss">
.is-active {
  color: #409eff;
  border-color: rgb(197.7, 225.9, 255);
  background-color: rgb(235.9, 245.3, 255);
  outline: none;
}

:deep(.el-button--small.is-circle) {
  width: 2rem;
}

:deep(.el-transfer__button) {
  border-radius: 50%;
  height: 32px;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0;
}

:deep(.el-transfer__button:first-child) {
  margin-bottom: 10px;
}
</style>
